package DataStructures.mySort;

/**
 * @Author: yqy
 * @Date: 2022/06/07/21:59
 * @Description:
 */
public class Select {
    public static int[] select(int[] arr){
        for (int i = 0; i < arr.length; i++) {
            int minIndex=i;
            int min=arr[i];
            for (int j = i+1; j < arr.length; j++) {
                if (min>arr[j]){
                    min=arr[j];
                    minIndex=j;
                }
            }
            if (minIndex!=i){
                arr[minIndex]=arr[i];
                arr[i]=min;
            }
        }
        return arr;
    }
}
